package com.itheima.job;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

public class Test01 {
    public static void main(String[] args) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        ArrayList<Integer> list = new ArrayList<>();
        //获取类对象
        Class clazz = list.getClass();

        //获得add方法
        Method method = clazz.getMethod("add", Object.class);
        //调用
        method.invoke(list,"hahaha");
        System.out.println(list);
    }
}
